﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>表单处理</title>
    <meta charset="utf-8" />
    <link href="../Scripts/easyUI145/themes/icon.css" rel="stylesheet" />
    <link href="../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" />
    <script src="../Scripts/easyUI145/jquery.min.js"></script>
    <script src="../Scripts/easyUI145/jquery.easyui.min.js"></script>
    <script src="../Scripts/QueryString.js"></script>
    <script src="../Scripts/config.js"></script>
    <script type="text/javascript">
        var mapdata = getQueryStringByName("FK_MapData");
        var oid = getQueryStringByName("OID");
        var isEdit = getQueryStringByName("IsEdit");
        var isPrint = getQueryStringByName("IsPrint");
        var isLoadData = getQueryStringByName("IsLoadData");
        var mdinfo;

        $(function () {

            if (isEdit.length == 0) {
                isEdit = "1";
            }

            if (isPrint.length == 0) {
                isPrint = "1";
            }

            if (isLoadData.length == 0) {
                isLoadData = "1";
            }

            var param = {
                DoType: 'FrmSingle_Init',
                FK_MapData: mapdata,
                OID: oid
            };

            Handler_AjaxQueryData(param, function (data) {
                if (data.indexOf("err@") != -1) {
                    $.messager.alert("错误", data, "error");
                    return;
                }

                mdinfo = eval('(' + data + ')');

                if (mdinfo.IsExist == "0") {
                    isEdit = "1";
                }

                if (isEdit != "1") {
                    $(document.body).layout("remove", "north");
                }

                oid = mdinfo.OID;

                var url = "./Frm.aspx?FK_MapData=" + mapdata + "&IsEdit=" + isEdit + "&IsPrint=" + isPrint + "&OID=" + oid + "&UserNo=" + mdinfo.UserNo + "&SID=" + mdinfo.SID + "&IsLoadData=" + isLoadData;
                var se = location.search.substr(1).split('&');
                var passed = "fk_mapdata=isedit=isprint=oid=userno=sid=isloaddata=m=";
                var si;

                for (var i = 0; i < se.length; i++) {
                    si = se[i].split('=');
                    if (si.length < 2) {
                        continue;
                    }

                    if (passed.indexOf(si[0].toLowerCase() + '=') == -1) {
                        url += '&' + se[i];
                    }
                }

                url += "&m=" + Math.random();

                document.getElementById("frmMain").src = url;
            }, this);
        });

        function SaveFrm() {
            var win = document.getElementById("frmMain").contentWindow;

            if (win && win.SaveDtlData) {
                win.isChange = true;
                win.SaveDtlData();
            }
            else {
                $.messager.alert("错误", "表单未加载或加载未完成", "error");
            }
        }
    </script>
</head>
<body class="easyui-layout">
    <div data-options="region:'north'" style="line-height:35px; padding-left:15px; height:40px;">
        <a href="javascript:void(0)" onclick="SaveFrm()" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>
    </div>
    <div data-options="region:'center'" style="overflow-y:hidden">
        <iframe id="frmMain" style="width:100%;height:100%" frameborder="0" scrolling="auto" src=""></iframe>
    </div>
</body>
</html>
